package controllers

import (
	"app/models"
	beego "github.com/beego/beego/v2/server/web"
	_ "github.com/go-sql-driver/mysql"
	"strconv"
)

type MainController struct {
	beego.Controller
}

func (c *MainController) Get() {
	c.Data["Website"] = "beego.me1"
	c.Data["Email"] = "astaxie@gmail.com"
	c.TplName = "index.tpl"
}

func (c *MainController) GetInfoList() {
	page := c.GetString("page")
	pageNum, _ := strconv.Atoi(page)
	pageNum--
	list := models.GetList(pageNum, "info")

	res := ReturnMsg{
		0,
		"success",
		list,
	}
	c.Data["json"] = res
	c.ServeJSON()
	c.StopRun()
}
